package com.huawei.appgallery.forum.cards.widget;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.ImageView;

public class ForumLineImageView extends ImageView {
    private RectF ˊ;
    protected Drawable ˋ;
    private Paint ˎ;
    private final Matrix ˏ;
    private int ॱ;
    private boolean ᐝ;

    public ForumLineImageView(android.content.Context r5, android.util.AttributeSet r6, int r7) {
        /* JADX: method processing error */
/*
Error: java.util.NoSuchElementException
	at java.util.HashMap$HashIterator.nextNode(HashMap.java:1444)
	at java.util.HashMap$KeyIterator.next(HashMap.java:1466)
	at jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract.applyRemove(BlockFinallyExtract.java:535)
	at jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract.extractFinally(BlockFinallyExtract.java:175)
	at jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract.processExceptionHandler(BlockFinallyExtract.java:79)
	at jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract.visit(BlockFinallyExtract.java:51)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:31)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:17)
	at jadx.core.ProcessClass.process(ProcessClass.java:37)
	at jadx.api.JadxDecompiler.processClass(JadxDecompiler.java:306)
	at jadx.api.JavaClass.decompile(JavaClass.java:62)
*/
        /*
        r4 = this;
        r0 = 0;
        r4.<init>(r5, r6, r7);
        r1 = new android.graphics.Matrix;
        r1.<init>();
        r4.ˏ = r1;
        r1 = new android.graphics.Paint;
        r1.<init>();
        r4.ˎ = r1;
        r1 = r4.ˎ;
        r2 = 1;
        r1.setAntiAlias(r2);
        if (r6 == 0) goto L_0x0068;
    L_0x001a:
        r1 = o.bsy$i.ᐝʽ;
        r2 = r5.obtainStyledAttributes(r6, r1, r7, r0);
        r1 = o.bsy$i.ᐧॱ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r2.hasValue(r1);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        if (r1 == 0) goto L_0x0069;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0028:
        r1 = o.bsy$i.ᐧॱ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r3 = 0;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r2.getDimensionPixelSize(r1, r3);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x002f:
        r4.ॱ = r1;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = o.bsy$i.ॱﾟ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r2.hasValue(r1);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        if (r1 == 0) goto L_0x006b;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0039:
        r1 = o.bsy$i.ॱﾟ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r3 = 0;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r2.getBoolean(r1, r3);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0040:
        if (r1 == 0) goto L_0x0078;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0042:
        r1 = o.bsy$i.ᐝʻ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r2.hasValue(r1);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        if (r1 == 0) goto L_0x006d;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x004a:
        r1 = o.bsy$i.ᐝʻ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r2.getDrawable(r1);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0050:
        r4.ˋ = r1;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0052:
        r1 = o.bsy$i.ᐝʼ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r2.hasValue(r1);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        if (r1 == 0) goto L_0x0061;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x005a:
        r0 = o.bsy$i.ᐝʼ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = 0;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r0 = r2.getBoolean(r0, r1);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0061:
        r4.ᐝ = r0;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        if (r2 == 0) goto L_0x0068;
    L_0x0065:
        r2.recycle();
    L_0x0068:
        return;
    L_0x0069:
        r1 = r0;
        goto L_0x002f;
    L_0x006b:
        r1 = r0;
        goto L_0x0040;
    L_0x006d:
        r1 = r4.getResources();	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r3 = o.bsy.a.ᐝॱ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r1.getDrawable(r3);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        goto L_0x0050;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0078:
        r1 = o.bsy$i.ᐝʻ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r2.hasValue(r1);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        if (r1 == 0) goto L_0x0097;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0080:
        r1 = o.bsy$i.ᐝʻ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r2.getDrawable(r1);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
    L_0x0086:
        r4.ˋ = r1;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        goto L_0x0052;
    L_0x0089:
        r0 = move-exception;
        r1 = "LineImageView";	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r3 = "CropRightRoundImageView init(AttributeSet attrs) ";	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        o.bqx.ˊ(r1, r3, r0);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        if (r2 == 0) goto L_0x0068;
    L_0x0093:
        r2.recycle();
        goto L_0x0068;
    L_0x0097:
        r1 = r4.getResources();	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r3 = o.bsy.a.ʽ;	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        r1 = r1.getDrawable(r3);	 Catch:{ RuntimeException -> 0x0089, all -> 0x00a2 }
        goto L_0x0086;
    L_0x00a2:
        r0 = move-exception;
        if (r2 == 0) goto L_0x00a8;
    L_0x00a5:
        r2.recycle();
    L_0x00a8:
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.appgallery.forum.cards.widget.ForumLineImageView.<init>(android.content.Context, android.util.AttributeSet, int):void");
    }

    public ForumLineImageView(Context context) {
        this(context, null);
    }

    public ForumLineImageView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (!isInEditMode() && this.ˋ != null) {
            this.ˋ.setBounds(0, 0, getWidth(), getHeight());
            this.ˋ.draw(canvas);
        }
    }

    protected void drawableStateChanged() {
        if (this.ˋ != null) {
            this.ˋ.setState(getDrawableState());
            invalidate();
        }
        super.drawableStateChanged();
    }

    protected void onDraw(Canvas canvas) {
        if (getDrawable() != null) {
            ˏ();
            if (this.ᐝ) {
                Path path = new Path();
                path.addRoundRect(this.ˊ, new float[]{(float) this.ॱ, (float) this.ॱ, (float) this.ॱ, (float) this.ॱ, 0.0f, 0.0f, 0.0f, 0.0f}, Direction.CW);
                canvas.drawPath(path, this.ˎ);
                return;
            }
            canvas.drawRoundRect(this.ˊ, (float) this.ॱ, (float) this.ॱ, this.ˎ);
        }
    }

    private void ˏ() {
        Drawable drawable = getDrawable();
        if (drawable != null) {
            Bitmap ˏ = ˏ(drawable);
            if (ˏ != null) {
                Shader bitmapShader = new BitmapShader(ˏ, TileMode.CLAMP, TileMode.CLAMP);
                float max = Math.max((((float) getWidth()) * 1.0f) / ((float) ˏ.getWidth()), (((float) getHeight()) * 1.0f) / ((float) ˏ.getHeight()));
                this.ˏ.setScale(max, max);
                bitmapShader.setLocalMatrix(this.ˏ);
                this.ˎ.setShader(bitmapShader);
            }
        }
    }

    private Bitmap ˏ(Drawable drawable) {
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        }
        int intrinsicWidth = drawable.getIntrinsicWidth();
        int intrinsicHeight = drawable.getIntrinsicHeight();
        if (intrinsicWidth <= 0 || intrinsicHeight <= 0) {
            return null;
        }
        Bitmap createBitmap = Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Config.ARGB_8888);
        Canvas canvas = new Canvas(createBitmap);
        drawable.setBounds(0, 0, intrinsicWidth, intrinsicHeight);
        drawable.draw(canvas);
        return createBitmap;
    }

    protected void onSizeChanged(int i, int i2, int i3, int i4) {
        super.onSizeChanged(i, i2, i3, i4);
        this.ˊ = new RectF(0.0f, 0.0f, (float) getWidth(), (float) getHeight());
    }

    public int ˎ(int i) {
        return (int) TypedValue.applyDimension(1, (float) i, getResources().getDisplayMetrics());
    }

    public void setBorderRadius(int i) {
        int ˎ = ˎ(i);
        if (this.ॱ != ˎ) {
            this.ॱ = ˎ;
            invalidate();
        }
    }
}
